/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.linde.enums;

/**
 * 文本类型枚举
 * 
 * @author Wien(luweien@aliyun.com)
 *
 */
public enum TextTypeEnum {

	/**
	 * 单行普通文本
	 */
	SIMPLE(0, "单行普通文本"),

	/**
	 * 多行普通文本
	 */
	MULTI(1, "多行普通文本"),

	/**
	 * HTML富文本
	 */
	HTML(2, "Html富文本"),

	/**
	 * Markdown富文本
	 */
	MARKDOWN(3, "Markdown富文本");

	private final int code;

	private final String message;

	private TextTypeEnum(int code, String message) {
		this.code = code;
		this.message = message;
	}

	/**
	 * @return Return the integer value of this status code.
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @return Return the reason phrase of this code.
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Return the enum constant of this type with the specified numeric value.
	 * @param code the numeric value of the enum to be returned
	 * @return the enum constant with the specified numeric value
	 * @throws IllegalArgumentException if this enum has no constant for the specified numeric value
	 */
	public static TextTypeEnum valueOf(int code) {
		for (TextTypeEnum textEnum : values()) {
			if (textEnum.getCode() == code) {
				return textEnum;
			}
		}
		throw new IllegalArgumentException("No matching constant for [" + code + "]");
	}
}
